<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
* FILE_NAME : index.class.php   FILE_PATH : \classes\application\index.class.php
* ....功能导航
*
* @copyright workflow_system 
* @author workflow Develop Team 
* @package 
* @subpackage 
* @version Fri Feb 22 10:19:24 CST 2008
*/
class IndexClass extends FrameWork {

	/**
	 * 首页功能导航信息统计
	 *
	 * @return array 返回统计信息数组
	 */
	function getIndexStatics(){
		$member_num = $GLOBALS['db']->CountRows("member"," member_state = '1'");
		$shop_num = $GLOBALS['db']->CountRows("shop_info"," ischeck = '1'");
		$product_num = $GLOBALS['db']->CountRows("product","");
		$product_selling = $GLOBALS['db']->CountRows("product"," p_state = '1'");
		$trade_num = $GLOBALS['db']->CountRows("product_sold"," sp_state != '5'");
		$trade_succ = $GLOBALS['db']->CountRows("product_sold"," sp_state = '3'");
		$trade_doing = $GLOBALS['db']->CountRows("product_sold"," sp_state = '0' or sp_state = '1' or sp_state = '2' or sp_state = '4'");
		$complaint_num = $GLOBALS['db']->CountRows("complaint_report"," c_r_handling_state = '0' and (c_r_class = '1' or c_r_class = '2')");
		$report_num = $GLOBALS['db']->CountRows("complaint_report"," c_r_handling_state = '0' and (c_r_class = '3' or c_r_class = '4')");
		$shop['member_num'] = $member_num?$member_num:0;
		$shop['shop_num'] = $shop_num?$shop_num:0;
		$shop['product_num'] = $product_num?$product_num:0;
		$shop['product_selling'] = $product_selling?$product_selling:0;
		$shop['trade_num'] = $trade_num?$trade_num:0;
		$shop['trade_succ'] = $trade_succ?$trade_succ:0;
		$shop['trade_doing'] = $trade_doing?$trade_doing:0;
		$shop['complaint_num'] = $complaint_num?$complaint_num:0;
		$shop['report_num'] = $report_num?$report_num:0;
		
		return $shop;
	}
	/**
	 * 获取数据库版本信息
	 *
	 * @return string
	 */
	function getDatabaseVersion(){
		$dbversion_row = $GLOBALS['db']->GetRow("SELECT VERSION()");
		$dbversion = $dbversion_row['0'];
		return $dbversion;
	}
	/**
	 * 获取数据库大小
	 *
	 * @return unknown
	 */
	function getDatabaseSize(){
		$this->getlang("sys_common");
		$dbsize = 0;
		$dbpre = $this->_configinfo['database']['dbprefix'];
		$dbtables = $GLOBALS['db']->GetArray("SHOW TABLE STATUS LIKE '%$dbpre%'");
		if (is_array($dbtables)){
			foreach ($dbtables as $value) {
				$dbsize += $value['Data_length'] + $value['Index_length'];
			}
		}
		$dbsize = $dbsize ? Common::filesize($dbsize) : $this->_lang['langSysCSealedSize'];
		return $dbsize;
	}
	
	/**
	 * 执行更新的SQL语句
	 */
	function updateSql($sql){
		$result = $GLOBALS['db']->Execute($sql);
		return $result;
	}
}
?>